// 发货单路由定义文件
// 该文件定义了发货单相关的API路由

const express = require('express');
const router = express.Router();

// 引入发货单路由处理函数
const { 
  getDeliveryOrders, 
  getDeliveryOrderById, 
  addDeliveryOrder, 
  updateDeliveryOrder, 
  deleteDeliveryOrder 
} = require('../router_handler/deliveryOrders');

// 引入中间件
const { addDeliveryOrderSchema, updateDeliveryOrderSchema } = require('../schema/deliveryOrders');
const { handleValidationErrors } = require('../middleware/validation');

/**
 * 获取发货单列表
 * GET /api/deliveryOrders/list
 */
router.get('/list', getDeliveryOrders);

/**
 * 根据ID获取发货单详情
 * GET /api/deliveryOrders/:id
 */
router.get('/:id', getDeliveryOrderById);

/**
 * 添加新的发货单
 * POST /api/deliveryOrders/add
 */
router.post('/add', addDeliveryOrderSchema, handleValidationErrors, addDeliveryOrder);

/**
 * 更新发货单信息
 * PUT /api/deliveryOrders/update
 */
router.put('/update', updateDeliveryOrderSchema, handleValidationErrors, updateDeliveryOrder);

/**
 * 删除发货单
 * DELETE /api/deliveryOrders/delete/:id
 */
router.delete('/delete/:id', deleteDeliveryOrder);

// 导出路由实例
module.exports = router;